package com.itheima.health.controller;

import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SetmealService;
import com.itheima.health.utils.resources.MessageConstant;
import com.itheima.health.vo.CheckGroupVO;
import com.itheima.health.vo.SetmealVO;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
public class SetmealMobileController {

    @Reference
    private SetmealService setmealService;


    //移动端查询所有套餐
    @GetMapping("setmeal/findAllSetmeal")
    public Result findAll() {
        try {

            List<Setmeal> list = setmealService.list();
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS, list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }

    //套餐详情
    @GetMapping("setmeal/findSetMealDetail")
    public Result findSetMealDetail(@RequestParam("id") int id) {
        try {
            SetmealVO setMealDetail = setmealService.findSetMealDetail(id);
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setMealDetail);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }
}
